package br.com.async.core.application.impl;

import br.com.async.core.application.EvaluateApplication;
import br.com.async.core.domain.bookmark.Evaluation;
import br.com.async.core.domain.enterprise.Enterprise;
import br.com.async.core.domain.enterprise.EnterpriseRepository;

public class EvaluateApplicationImpl implements EvaluateApplication {

	private EnterpriseRepository enterpriseRepository;

	public EvaluateApplicationImpl(EnterpriseRepository enterpriseRepository) {
		super();
		this.enterpriseRepository = enterpriseRepository;
	}

	@Override
	public void evaluate(Integer enterpriseCode, Evaluation evaluation) {
		Enterprise enterprise = enterpriseRepository.findById(enterpriseCode);

		enterprise.getEvaluation().add(evaluation);
		try {
			enterpriseRepository.update(enterprise);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
